﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = $.request("keyValue");
    var filesList = [], photoList = [], videoList = [];
    var Spacedata = [];
    var filesListDel = [], photoListDel = [], videoListDel = [];
    var itemList;
    var userList;
    var site_type = '', city = "", district = "", provinces = "", business = "";
    var formid = '';
    var userinfo;
    var roleinfo;
    var result;
    $(function () {
        userinfo = getCache("DLXX");        
        formid = keyValue;
        getItemList();
        getDistrict(0);
        getUserList();       
        if (keyValue != 'SiteForm') {
            $("#ul_nav-tabs").css("display", "");
            $("#li_profile").css("display", "");
            getSiteSpaeFrom();
            ActivitiesgridList(itemList);
        }
        else {
            $("#ul_nav-tabs").css("display", "");
            $("#li_profile").css("display", "none");
            $("#li_Activities").css("display", "none");
        }
        gridSpaceList(itemList);
        $('#getPoint').click(function () {
            if ($('#address').val() == '') {
                $.modalAlert("请填写正确的场地地址！", "warning");
                return;
            }
            getPoint();
        })

        if (keyValue != "SiteForm" && userinfo != null) {
            roleinfo = top.clients.role[userinfo.F_RoleId];
            if (roleinfo != null) {
                if (result.siteEntity.Mocha_ITOM != userinfo.F_Id) {
                    if (roleinfo.encode == "1004" || roleinfo.encode == "1006" || roleinfo.encode == "1005" || roleinfo.encode == "1012") {
                        $(".showContact").hide();
                        $("#F_AttachmentPptBtn").hide();
                        $("#F_AttachmentBtn").hide();
                        $("#F_submitBtn").hide();
                        $("#NF-add").hide();
                        $("#NF-edit").hide();
                        $("#NF-editAllPrice").hide();
                        $("#NF-Server").hide();
                        $("#NF-schedule").hide();
                        $("#ActivitiesNF-add").hide();
                        $("#ActivitiesNF-edit").hide();
                        $("#ActivitiesNF-delete").hide();
                    }
                }
            }
        }

        $("#PhotoFile").change(function () {
            $("#displaydiv").empty();
            for (var i = 0, j = this.files.length; i < j; i++) {
                $("#displaydiv").append("<img name='" + this.files[i].name + "' src=\"" + window.URL.createObjectURL(this.files[i]) + "\">");
            }
        });
    });

    function getSiteSpaeFrom() {
        $.ajax({
            url: "/SiteManage/Site/GetFormJson",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            success: function (data) {
                provinces = data.siteEntity.provinces_id;
                city = data.siteEntity.city_id;
                district = data.siteEntity.district_id;
                business = data.siteEntity.business_area;
                $("#form1").formSerialize(data.siteEntity);
                site_type = data.siteEntity.site_type;
                $("#form2").formSerialize(data.theContractEntity);
                $("#form3").formSerialize(data.financialEntity);
                if ($.trim(data.siteEntity.F_AttachmentPpt)) {
                    var urllist = data.siteEntity.F_AttachmentPpt.split('/');
                    document.getElementById("F_AttachmentPptA").innerHTML = urllist[urllist.length - 1];
                    $("#F_AttachmentPptA").show().attr('href', data.siteEntity.F_AttachmentPpt);
                }
                if ($.trim(data.siteEntity.F_Attachment)) {
                    var urllist = data.siteEntity.F_Attachment.split('/');
                    document.getElementById("F_AttachmentA").innerHTML = urllist[urllist.length - 1];
                    $("#F_AttachmentA").show().attr('href', data.siteEntity.F_Attachment);
                }

                filesList = data.FilesList;
                getFilesListHtml();

                photoList = data.PhotosList;
                getPhotoListHtml();

                videoList = data.VideoList;
                getVideoListHtml();

                GetSupplierName();
                if (data.siteEntity.db_admin_id) {
                    GetUserName(data.siteEntity.db_admin_id, "BD");
                }
                if (data.siteEntity.Mocha_ITOM) {
                    GetUserName(data.siteEntity.Mocha_ITOM, "Mocha_ITOM");
                }
                if (data.siteEntity.F_Facilities) {
                    var Facilities = data.siteEntity.F_Facilities.split('|');
                    $("#F_Facilities").val(Facilities).trigger("change");
                }
                if (data.siteEntity.site_event_type) {
                    var eventtypes = data.siteEntity.site_event_type.split(',');
                    $("#site_event_type").val(eventtypes).trigger("change");
                }
            }
        });
    }

    //动态获取文件HTML
    function getFilesListHtml() {
        $("#imgrq").empty();
        for (var i = 0, j = filesList.length; i < j; i++) {
            var url = "";
            url = h + filesList[i].F_path + "?v=" + RndNum(10);
            $("#imgrq").append("<div style='float:left;margin-right:30px;'><a target='_blank'  href='" + url + "'>" +
                filesList[i].name + "</a></div>");
        }
    }


    var h = "http://storage.yunspace.com.cn/";
    //动态获取图片HTML
    function getPhotoListHtml() {
        $("#photoList").empty();
        for (var i = 0, j = photoList.length; i < j; i++) {
            var cha = "", is_Emphasis = "";
            if (photoList[i].is_cover) {
                cha = "checked";
            }
            if (photoList[i].F_IsEmphasis) {
                is_Emphasis = "checked";
            }
            var url = "";
            url = h + photoList[i].F_path + "?" + Math.random();
            $("#photoList").append("<div class='imgList'><div class='imglink' id='" + i
                + "' onclick='checkDownload(this.id)'><input type='checkbox' class='isDownload' id='Down" + i
                + "' name= 'isDownload' value= '" + i + "' ><img id='img" + photoList[i].F_Id
                + "' style= 'width:120px; height:100px;' /></div><div><input type='text' disabled='disabled'  id='"
                + photoList[i].F_Id + "' class='form-control imgtag' onChange=\"uptag('" + photoList[i].F_Id + "', this.value,photoList)\" value='" + photoList[i].tag
                + "' placeholder='参考：外观图1 / 控制台' /><input type='radio' disabled='disabled' class='rdio' " + cha + " id='radio" + photoList[i].F_Id
                + "' name='is_cover' value='" + photoList[i].F_Id + "' />首图<input type='checkbox' " + is_Emphasis + " disabled='disabled'  id='checkbox" + photoList[i].F_Id
                + "' name='is_Emphasis' value='" + photoList[i].F_Id + "' />重点<a class='big_photo' target='_blank'  href='" + url + "'>大图</a></div></div >");
            $("#img" + photoList[i].F_Id).attr('src', src = url);
        }
    }
    //动态获取小视频HTML
    function getVideoListHtml() {
        $("#VideoList").empty();
        for (var i = 0; i < videoList.length; i++) {
            var cha = "", is_Emphasis = "";
            if (videoList[i].is_cover) {
                cha = "checked";
            }
            var url = "";
            url = h + videoList[i].F_path + "?v=" + RndNum(14);
            $("#VideoList").append("<div class='video'><video style= 'width:150px; height:220px;' src='" + url + "' controls preload='auto'></video ><div><input type='text' id='"
                + videoList[i].F_Id + "' class='form-control videotag' disabled='disabled'  onChange=\"uptag('" + videoList[i].F_Id + "', this.value,videoList)\" value='" + videoList[i].tag
                + "' placeholder='参考：外观图1 / 控制台' /><input type='radio' class='rdio' " + cha + " id='radio" + videoList[i].F_Id
                + "' name='videois_cover' disabled='disabled'  value='" + videoList[i].F_Id + "' />优选</div></div >");
        }
    }

    function checkDownload(id) {
        document.getElementById("Down" + id).checked = document.getElementById("Down" + id).checked ? false : true;
    }

    function downloadImage(src) {
        var $a = $("<a></a>").attr("href", src).attr("download", "meitu.png");
        $a[0].click();
    }
    var is_Down = 0;
    //获取需要下载的图片
    function checkIsDown() {
        if (photoList.length > 0) {
            var $selectedvalue = $("input[name='isDownload']");
            for (var i = 0; i < photoList.length; i++) {
                if ($selectedvalue[i].checked && i == $selectedvalue[i].value) {
                    is_Down += 1;
                    downloadImage(h + photoList[i].F_path);
                }
            }
        } else {
            $.modalAlert("请先上传场地图片!", "warning");
        }
        if (is_Down == 0) {
            $.modalAlert("请先点击图片选择您要下载的项目!", "warning");
        }
    }
    

    
    function getItemList() {
        itemList = getCache("SJZD");
        if (!itemList || itemList.length <= 0) {
            $.ajax({
                url: "/SiteManage/Site/GetItemListJson",
                dataType: "json",
                async: false,
                success: function (data) {
                    itemList = data;
                    initControl(data);
                    setCache("SJZD", itemList);
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log(XMLHttpRequest);
                    console.log(textStatus);
                    console.log(errorThrown);
                }
            });
        }
        else {
            initControl(itemList);
        }
    }
    function GetSupplierName() {
        $.ajax({
            url: "/SiteManage/Supplier/GetSupplierName",
            dataType: "json",
            data: { F_Id: $("#F_SupplierId").val() },
            async: false,
            success: function (data) {
                if (data && data.Sname.length > 0) {
                    $("#supplier").val(data.Sname[0].name);
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function GetUserName(f_id, type) {
        $.ajax({
            url: "/SystemManage/User/GetFormJson",
            dataType: "json",
            data: { keyValue: f_id },
            async: false,
            success: function (userdata) {
                result = userdata;
                if (userdata) {
                    if (type == "BD") {
                        $("#db_admin").val(userdata.F_RealName);
                    }
                    else if (type == "Mocha_ITOM") {
                        $("#Mocha_ITOM_admin").val(userdata.F_RealName);
                    }
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }

    function getDistrict(type) {
        var pidValue, actionid;
        if (type == "city") {
            pidValue = $("#provinces_id").val();
            actionid = "city_id";
        }
        else if (type == 'district') {
            pidValue = $("#city_id").val()
            actionid = "district_id";
        }
        else if (type == 'business') {
            pidValue = $("#district_id").val();
            actionid = "business_area";
        }
        else {
            pidValue = 0;
            actionid = "provinces_id";
        }
        $.ajax({
            url: "/SystemManage/Area/GetListByParentId?code=" + pidValue,
            dataType: "json",
            async: false,
            success: function (data) {
                CityControl(data, type, actionid);
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }
    function CityControl(ItemList, type, actionid) {
        var items = ItemList; var bindid;
        if (type == "city") {
            bindid = $("#city_id,#district_id,#business_area");
            bindid.empty();
            $("#city_id").append("<option value=''>==请选择城市数据==</option>");
            $("#district_id").append("<option value=''>==请选择行政区域==</option>");
            $("#business_area").append("<option value=''>==请选择商圈==</option>");
        }
        else if (type == "district") {
            bindid = $("#district_id,#business_area");
            bindid.empty();
            $("#district_id").append("<option value=''>==请选择行政区域==</option>");
            $("#business_area").append("<option value=''>==请选择商圈==</option>");
        }
        else if (type == "business") {
            bindid = $("#business_area");
            bindid.empty();
            $("#business_area").append("<option value=''>==请选择商圈==</option>");
        }
        else {
            bindid = $("#city_id,#district_id,#business_area,#provinces_id");
            bindid.empty();
            $("#provinces_id").append("<option value=''>==请选择省份==</option>");
            $("#city_id").append("<option value=''>==请选择城市数据==</option>");
            $("#district_id").append("<option value=''>==请选择行政区域==</option>");
            $("#business_area").append("<option value=''>==请选择商圈==</option>");
        }
        for (var i = 0; i < items.length; i++) {
            if (type == 0 && items[i].F_Id == provinces) {
                $("#" + actionid).append("<option selected='selected' value='" + items[i].F_Id + "'>" + items[i].F_FullName + "</option>");
            }
            else if (type == "city" && items[i].F_Id == city) {
                $("#" + actionid).append("<option selected='selected' value='" + items[i].F_Id + "'>" + items[i].F_FullName + "</option>");
            }
            else if (type == "district" && items[i].F_Id == district) {
                $("#" + actionid).append("<option selected='selected' value='" + items[i].F_Id + "'>" + items[i].F_FullName + "</option>");
            }
            else if (type == 'business' && items[i].F_Id == business) {
                $("#" + actionid).append("<option selected='selected' value='" + items[i].F_Id + "'>" + items[i].F_FullName + "</option>");
            }
            else {
                $("#" + actionid).append("<option value='" + items[i].F_Id + "'>" + items[i].F_FullName + "</option>");
            }
        }
        if (formid.length > 10) {
            if (type == 'city' && $("#provinces_id").val() == provinces) {
                getDistrict("district");
            } else if (type == 'district' && $("#city_id").val() == city) {
                getDistrict("business");
            }
        }
        bindid.select2();
    }

    var ActivityType = [];
    function initControl(ItemList) {
        ActivityType = ItemList.ActivityType;
        var sitetype = ItemList.SiteType;
        for (var i = 0; i < sitetype.length; i++) {
            $("#site_type").append("<option value='" + sitetype[i].F_ItemCode + "'>" + sitetype[i].F_ItemName + "</option>");
        }
        var SiteState = ItemList.SiteState;
        for (var i = 0; i < SiteState.length; i++) {
            $("#state").append("<option value='" + SiteState[i].F_ItemCode + "'>" + SiteState[i].F_ItemName + "</option>");
        }
        var SecondTypes = ItemList.SecondTypes;
        for (var i = 0; i < SecondTypes.length; i++) {
            $("#second_type").append("<option value='" + SecondTypes[i].F_ItemCode + "'>" + SecondTypes[i].F_ItemName + "</option>");
        }
        var SiteLevel = ItemList.SiteLevel;
        for (var i = 0; i < SiteLevel.length; i++) {
            $("#level").append("<option value='" + SiteLevel[i].F_ItemCode + "'>" + SiteLevel[i].F_ItemName + "</option>");
        }
        var Category = ItemList.Category;
        for (var i = 0; i < Category.length; i++) {
            $("#F_Category").append("<option value='" + Category[i].F_ItemCode + "'>" + Category[i].F_ItemName + "</option>");
        }
        var Siteident = ItemList.Siteident;
        for (var i = 0; i < Siteident.length; i++) {
            $("#ident").append("<option value='" + Siteident[i].F_ItemCode + "'>" + Siteident[i].F_ItemName + "</option>");
        }
        var Distance = ItemList.Distance;
        for (var i = 0; i < Distance.length; i++) {
            $("#subway_distance").append("<option value='" + Distance[i].F_ItemCode + "'>" + Distance[i].F_ItemName + "</option>");
        }

        var Facilities = ItemList.Facilities;
        for (var i = 0; i < Facilities.length; i++) {
            var jsonvalue = { n: Facilities[i].F_ItemCode };
            $("#F_Facilities").append("<option value='" + JSON.stringify(jsonvalue) + "'>" + Facilities[i].F_ItemName + "</option>");
        }
        var site_style = ItemList.site_style;
        for (var i = 0; i < site_style.length; i++) {
            $("#site_style").append("<option value='" + site_style[i].F_ItemCode + "'>" + site_style[i].F_ItemName + "</option>");
        }
        var hzms = ItemList.hzms;
        for (var i = 0; i < hzms.length; i++) {
            $("#F_CooperationMode").append("<option value='" + hzms[i].F_ItemCode + "'>" + hzms[i].F_ItemName + "</option>");
        }
        var htzt = ItemList.htzt;
        for (var i = 0; i < htzt.length; i++) {
            $("#F_ContractState").append("<option value='" + htzt[i].F_ItemCode + "'>" + htzt[i].F_ItemName + "</option>");
        }
        var ContractWay = ItemList.ContractWay;
        for (var i = 0; i < ContractWay.length; i++) {
            $("#F_PaymentMethod").append("<option value='" + ContractWay[i].F_ItemCode + "'>" + ContractWay[i].F_ItemName + "</option>");
        }
        var payment = ItemList.payment;
        for (var i = 0; i < payment.length; i++) {
            $("#F_ContractWay").append("<option value='" + payment[i].F_ItemCode + "'>" + payment[i].F_ItemName + "</option>");
        }
        var InvoiceType = ItemList.InvoiceType;
        for (var i = 0; i < InvoiceType.length; i++) {
            $("#F_InvoiceType").append("<option value='" + InvoiceType[i].F_ItemCode + "'>" + InvoiceType[i].F_ItemName + "</option>");
        }
        var SiteTrait = ItemList.SiteTrait;
        for (var i = 0; i < SiteTrait.length; i++) {
            $("#F_Keywords").append("<option value='" + SiteTrait[i].F_ItemCode + "'>" + SiteTrait[i].F_ItemName + "</option>");
        }
        for (var i = 0; i < ActivityType.length; i++) {
            $("#site_event_type").append("<option value='" + ActivityType[i].F_ItemCode + "'>" + ActivityType[i].F_ItemName + "</option>");
        }

        $("#site_type").bindSelect()//场地类型
        $("#state").bindSelect()//场地状态
        $("#second_type").bindSelect()//场地次要类型
        $("#level").bindSelect()//场地级别
        $("#F_Category").bindSelect()//场地形态
        $("#ident").bindSelect()//认证
        $("#subway_distance").bindSelect()//距离地铁站
        $("#site_style").bindSelect()//场地调性
        //$("#site_event_type").bindSelect();//活动类型
        var mulitiples = $("#F_Facilities,#site_event_type");
        mulitiples.bindSelect({
            multiple: true
        });     //配套设施

        $("#F_CooperationMode").bindSelect();//合作模式
        $("#F_ContractWay").bindSelect();//签约方式
        $("#F_PaymentMethod").bindSelect();//结算方式
        $("#F_ContractState").bindSelect();//合同状态
        $("#F_InvoiceType").bindSelect();//发票类型

        $("#F_Keywords").bindSelect();//使用特点
        $("#F_OpenInvoiceDate").bindSelect();//开票时间
    }
    
    function setSupplier_id(value, id) {
        $("#F_SupplierId").val(id);
        $("#supplier").val(value);
    }

    function setDBuser(value, id) {
        $("#db_admin_id").val(id);
        $("#db_admin").val(value);
    }
    function setMocha_ITOMuser(value, id) {
        $("#Mocha_ITOM").val(id);
        $("#Mocha_ITOM_admin").val(value);
    }

    function gridSpaceList(ItemList) {
        var $spacegridList = $("#Space_gridList");
        var queryJson = {
            F_SiteId: keyValue
        }
        $spacegridList.dataGrid({
            url: "/SiteManage/Space/GetGridSpaceJson",
            postData: { queryJson: JSON.stringify(queryJson) },
            height: $(window).height() - 206,
            width: $(window).width - 306,
            autowidth: false,
            shrinkToFit: true,
            colModel: [
                { label: '空间名称', name: 'title', width: 150, align: 'left' },
                { label: '容纳人数', name: 'max_seating_capacity', width: 100, align: 'left' },
                { label: '利润率', name: 'porfit_rate', width: 80, align: 'left' },
                { label: '刊例价', name: 'F_MarketPrice', width: 80, align: 'left' },
                { label: 'YUNSPACE价', name: 'F_YunPrice', width: 80, align: 'left' },
                { label: '', name: 'F_FloorPrice', hidden: true },
                {
                    label: '价格单位', name: 'F_Units', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        return FMDictionaries(ItemList.units, cellvalue);
                    }
                },
                { label: '面积', name: 'area', width: 80, align: 'left' },
                { label: '层高', name: 'height', width: 80, align: 'left' },
                {
                    label: '状态', name: 'state', width: 60, align: 'left',
                    formatter: function (cellvalue) {
                        return FMDictionaries(ItemList.SiteState, cellvalue);
                    }
                },
                {
                    label: '更新时间', name: 'F_LastModifyTime', width: 150, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }
                },
                { label: '', name: 'F_Id', hidden: true },
            ],
            pager: "#gridPager",
            sortname: 'F_Id desc',
            viewrecords: true,
            ondblClickRow: function (rowid, iRow, iCol, e) {
                btn_edit();
            }
        });
        $(".ui-jqgrid,.ui-jqgrid-view,.ui-jqgrid-htable,.ui-jqgrid-hdiv,.ui-jqgrid-bdiv,.ui-jqgrid-pager").css("width", function () { return "100%"; });
        $(".ui-jqgrid-btable").css("width", function () { return "99%"; });

    }

    function getUserList() {
        $.ajax({
            url: "/SystemManage/User/GetUsersJson",
            dataType: "json",
            async: false,
            success: function (data) {
                userList = data;
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }
    function FMDictionaries(state, cellvalue) {
        if (cellvalue != undefined) {
            for (var i = 0; i < state.length; i++) {
                if (state[i].F_ItemCode.toString() === cellvalue.toString()) {
                    cellvalue = state[i].F_ItemName;
                    break;
                }
            }
        }
        return cellvalue;
    }
    function btn_editServer() {
        var F_Id = $("#Space_gridList").jqGridRowValue().F_Id;
        if (F_Id) {
            $.modalOpen({
                id: keyValue,
                title: "增值服务",
                url: "/SiteManage/ServicesCost/Index?type=disabled&spaceId=" + F_Id + "&F_SiteId=" + keyValue,
                width: "1200px",
                height: "720px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        } else {
            $.modalAlert("请先选择您要修改的空间数据！", "warning");
        }
    }

    function btn_schedule() {
        var F_Id = $("#Space_gridList").jqGridRowValue().F_Id;
        if (F_Id) {
            $.modalOpen({
                id: "schedule",
                title: "空间档期",
                url: "/SiteManage/Space/Schedule?type=disabled&keyValue=" + F_Id + "&SiteId=" + keyValue,
                width: "1000px",
                height: "720px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        } else {
            $.modalAlert("请先选择您要修改的空间数据！", "warning");
        }
    }

   
    function nub() {
        var value = $("#sort_index").val();
        if (/^([1-9]\d{0,1}|100|0)$/.test(value)) {
        } else {
            $.modalAlert('请输入1~100之间的优先排序序号', "warning");
        }
    }

    //使页面不可编辑
    function disableOcx() {
        var form = document.forms[0];
        for (var i = 0; i < form.length; i++) {
            var element = form.elements[i];
            //部分元素可以编号 element.name 是元素自定义 name
            if (element.name != "auditEntity.auditContent"
                && element.name != "auditEntity.auditAutograph"
                && element.name != "auditEntity.auditTime"
                && element.name != "auditEntity.auditState"
                && element.name != "submitBtn"
                && element.name != "reset"
                && element.name != "id"
                && element.name != "processInstanceId"
                && element.name != "updateForm") {
                element.disabled = "true";
            }
        }
        var form1 = document.forms[1];
        for (var i = 0; i < form1.length; i++) {
            var element = form1.elements[i];
            //部分元素可以编号 element.name 是元素自定义 name
            if (element.name != "auditEntity.auditContent"
                && element.name != "auditEntity.auditAutograph"
                && element.name != "auditEntity.auditTime"
                && element.name != "auditEntity.auditState"
                && element.name != "submitBtn"
                && element.name != "reset"
                && element.name != "id"
                && element.name != "processInstanceId"
                && element.name != "updateForm") {
                element.disabled = "true";
            }
        }
        var form2 = document.forms[2];
        for (var i = 0; i < form2.length; i++) {
            var element = form2.elements[i];
            //部分元素可以编号 element.name 是元素自定义 name
            if (element.name != "auditEntity.auditContent"
                && element.name != "auditEntity.auditAutograph"
                && element.name != "auditEntity.auditTime"
                && element.name != "auditEntity.auditState"
                && element.name != "submitBtn"
                && element.name != "reset"
                && element.name != "id"
                && element.name != "processInstanceId"
                && element.name != "updateForm") {
                element.disabled = "true";
            }
        }
    }
    window.onload = disableOcx;//当页面加载的时候执行此函数
    //取消不可编辑
    function noDisable() {
        var form = document.forms[0];
        for (var i = 0; i < form.length; i++) {
            var element = form.elements[i];
            element.disabled = false;
        }
    } 
</script>

<style type="text/css">
    .xbtn {
        position: absolute;
        right: 5px;
        top: 5px;
        z-index: 10;
    }

    .filedel {
        margin-left: 10px;
        color: red;
    }

    .form .formValue .input-group .btn {
        height: 20px !important;
    }

    .photodel {
        margin-left: 40px;
        color: red;
    }

    .big_photo {
        margin-left: 40px;
        color: dimgrey;
    }
    .imgtag {
        width: 95px !important;
        height: 10px !important;
        text-align: center;
        margin-top: 10px;
        margin-bottom: 5px;
    }

    #photoList {
        margin-left: 40px;
        height: 190px;
    }

        #photoList .imglink {
            position: relative;
            cursor: pointer;
            height: 100px;
            width: 120px;
        }


    .isDownload {
        position: absolute;
        right: 5px;
        top: 5px;
    }

    .imgList {
        float: left;
        width: 120px;
        height: 170px;
        margin: 10px;
        text-align: left;
    }

    .videotag {
        width: 150px !important;
        height: 20px !important;
        text-align: center;
        margin-top: 10px;
    }

    .video {
        float: left;
        width: 150px;
        height: 260px;
        margin: 10px;
        text-align: left;
    }
</style>
<ul id="ul_nav-tabs" class="nav nav-tabs" style="display:none">
    <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">场地信息</a></li>
    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">空间列表</a></li>
    <li role="presentation"><a href="#Activities" aria-controls="Activities" role="tab" data-toggle="tab">场地活动案例</a></li>
    @*<li role="presentation"><a href="#success" aria-controls="success" role="tab" data-toggle="tab">成交记录</a></li>*@
    @*<li role="presentation"><a href="#Jump" aria-controls="Jump" role="tab" data-toggle="tab">跳单记录</a></li>*@
</ul>

<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="home">
        <form id="form1">
            <div style="padding-top: 20px;">
                <table class="form" style="margin-top:3px;">
                    <tr class="showContact">
                        <td colspan="6" class="interval">联系人信息</td>
                    </tr>
                    <tr class="showContact">
                        <th class="formTitle">联系人<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="F_contact" name="F_contact" maxlength="20" type="text" class="form-control required" placeholder="请录入联系人" />
                        </td>
                        <th class="formTitle">手机号<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="F_phone" name="F_phone" maxlength="20" type="text" class="form-control required" placeholder="请录入手机号" />
                        </td>
                        <th class="formTitle">座机</th>
                        <td class="formValue">
                            <input id="F_telephone" name="F_telephone" maxlength="20" type="text" class="form-control" placeholder="请录入座机" />
                        </td>
                    </tr>
                    <tr class="showContact">
                        <th class="formTitle">邮箱<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="F_email" name="F_email" maxlength="50" type="text" class="form-control required" placeholder="请录入邮箱" />
                        </td>
                        <th class="formTitle">联系人职位</th>
                        <td class="formValue">
                            <input id="F_contact_position" maxlength="50" name="F_contact_position" type="text" class="form-control" placeholder="请录入联系人职位" />
                        </td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td colspan="6" class="interval">基础数据</td>
                    </tr>
                    <tr>
                        <th class="formTitle">场地名称<span style="color:red">*</span></th>
                        <td class="formValue"><input id="title" name="title" maxlength="40" type="text" class="form-control required" placeholder="请录入场地名称" /></td>
                        <th class="formTitle">场地别名</th>
                        <td class="formValue"><input id="nickname" name="nickname" maxlength="100" type="text" class="form-control" placeholder="请录入场地别名" /></td>

                        <th class="formTitle">省份<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="provinces_id" onchange="getDistrict('city')" name="provinces_id" class="form-control required"></select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">城市<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="city_id" onchange="getDistrict('district')" name="city_id" class="form-control required"></select>
                        </td>
                        <th class="formTitle">行政区域<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="district_id" name="district_id" onchange="getDistrict('business')" class="form-control required"></select>
                        </td>
                        <th class="formTitle">商圈<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="business_area" name="business_area" class="form-control required"></select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">地址<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="address" name="address" type="text" maxlength="150" class="form-control required" placeholder="请录入地址" />
                            <input id="getPoint" type="button" class="xbtn btn btn-primary" value="获取坐标" />
                        </td>
                        <th class="formTitle">X坐标值<span style="color:red">*</span></th>
                        <td class="formValue" style="position:relative">
                            <input id="x_coordinates" name="x_coordinates" class="form-control required" oninput="if(value.length>15)value=value.slice(0,15)" type="number" />
                        </td>
                        <th class="formTitle">Y坐标值<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="y_conrdinates" name="y_conrdinates" class="form-control required" oninput="if(value.length>15)value=value.slice(0,15)" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">场地类型<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="site_type" name="site_type" class="form-control required">
                                <option value="">==请录入场地类型==</option>
                            </select>
                        </td>
                        <th class="formTitle">次要类型<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="second_type" name="second_type" class="form-control required">
                                <option value="">==请录入次要类型==</option>
                            </select>
                        </td>
                        <th class="formTitle">场地级别<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="level" name="level" class="form-control required">
                                <option value="">==请录入场地级别==</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">场地风格</th>
                        <td class="formValue">
                            <select id="site_style" name="site_style" class="form-control">
                                <option value="">==请录入场地风格==</option>
                            </select>
                        </td>
                        <th class="formTitle">是否支持线上支付<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="F_Category" name="F_Category" class="form-control required">
                                <option value="">==是否支持线上支付==</option>
                            </select>
                        </td>
                        <th class="formTitle">停车位(个)</th>
                        <td class="formValue"><input id="parking_space" name="parking_space" type="number" oninput="if(value.length>8)value=value.slice(0,8)" class="form-control" placeholder="参考填写  200" /></td>
                    </tr>
                    <tr>
                        <th class="formTitle">距地铁里程</th>
                        <td class="formValue">
                            <select id="subway_distance" name="subway_distance" class="form-control">
                                <option value="">==请录入距离地铁站里程==</option>
                            </select>
                        </td>
                        <th class="formTitle">离核心市区距离</th>
                        <td class="formValue"><input id="loop_distance" name="loop_distance" maxlength="100" type="text" class="form-control" placeholder="请录入距离核心市区距离" /></td>
                        <th class="formTitle">核心市区</th>
                        <td class="formValue"><input id="loop_info" name="loop_info" type="text" maxlength="100" class="form-control" placeholder="请录入核心市区" /></td>
                    </tr>
                    <tr>
                        <th class="formTitle">周边商场名称</th>
                        <td class="formValue"><input id="around_market" name="around_market" maxlength="100" type="text" class="form-control" placeholder="请录入周边商场名称" /></td>
                        <th class="formTitle">周边写字楼租金（元/天/平）</th>
                        <td class="formValue"><input id="rent_office_building" name="rent_office_building" maxlength="100" type="text" class="form-control" placeholder="参考填写：1.2" /></td>
                        <th class="formTitle">周边住宅售价(元/平)</th>
                        <td class="formValue">
                            <input id="rent_residential_building" name="rent_residential_building" maxlength="100" type="text" class="form-control" placeholder="参考填写:  20000" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">配套设施<span style="color:red">*</span></th>
                        <td colspan="5" class="formValue">
                            <select id="F_Facilities" name="F_Facilities" class="form-control required" multiple></select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">活动类型<span style="color:red">*</span></th>
                        <td colspan="5" class="formValue">
                            <select id="site_event_type" name="site_event_type" class="form-control required"></select>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">场地介绍<span style="color:red">*</span></th>
                        <td colspan="5" class="formValue">
                            <textarea id="brand_story" name="brand_story" class="form-control required" maxlength="600" style="height:85px" placeholder="(字数控制300字内)参考填写：云SPACE 上海中成智谷秀场位于中成智谷产业园，宝山区长江路258号逸仙路长江路出口处,项目以商务办公，创意创业，现代产业园为主体，区域内商业的时尚汇聚地和潮流风向标业态满足目标客户需求的，更丰富贴切的吸引更多的品牌概念客户在项目中形成集聚效应。云SPACE秀场位于中成智谷产业园，宝山区长江路258号逸仙路长江路出口处。淞发路地铁站往北100米左右有一条货运铁路，原是上钢一厂专用线，直接穿过秀场正门！地铁3号线淞发路下站后，可以乘坐小火车直达秀场，成为了秀场活动的特色元素，仪式感爆棚！"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">推荐理由<span style="color:red">*</span></th>
                        <td colspan="5" class="formValue">
                            <input id="recommend_reason" name="recommend_reason" class="form-control required" maxlength="100" placeholder="参考填写 ：超酷的大台阶，挑高9米的专业秀场，还有颇具年代感的小火车直达秀场门口，仪式感爆棚！" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">附件PDF</th>
                        <td class="formValue" colspan="2"><a target="_blank" title="点击下载文件" href="javascript:void(0)" id="F_AttachmentA">点击查看->PDF</a></td>
                        <td class="formValue"><input type="button" value="上传PDF" onclick="OpenUpFile('PDF')" class=" btn btn-primary" id="F_AttachmentBtn"></td>
                        <td class="formValue"><input type="hidden" id="F_Attachment" name="F_Attachment" value="" /></td>
                    </tr>
                    <tr>
                        <th class="formTitle">附件PPT<span style="color:red">*</span></th>
                        <td class="formValue" colspan="2"><a target="_blank" title="点击下载文件" href="javascript:void(0)" id="F_AttachmentPptA">点击查看->PPT</a></td>
                        <td class="formValue"><input type="button" value="上传PPT" onclick="OpenUpFile('PPT')" class="btn btn-primary" id="F_AttachmentPptBtn"></td>
                        <td class="formValue"><input type="hidden" id="F_AttachmentPpt" name="F_AttachmentPpt" value="" /></td>
                    </tr>
                    <tr>
                        <td colspan="6" class="interval">场地管理</td>
                    </tr>
                    <tr>
                        @*<th class="formTitle">供应商</th>
                        <td class="formValue">
                            <input id="F_SupplierId" name="F_SupplierId" type="hidden" value="" />
                                <input id="supplier" name="supplier" type="text" class="form-control" placeholder="请录入供应商" />
                        </td>*@
                        <th class="formTitle">配合度</th>
                        <td class="formValue" colspan="3"><input id="advantage" name="advantage" maxlength="100" type="text" class="form-control" placeholder="参考填写：对我们很认可，配合度高/之前推过很多场地不成交，目前态度冷淡" /></td>
                    </tr>
                    <tr>
                        <th class="formTitle">认证<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="ident" name="ident" class="form-control">
                                <option value="">==请录入认证情况==</option>
                            </select>
                        </td>
                        <th class="formTitle">上线状态<span style="color:red">*</span></th>
                        <td class="formValue">
                            <select id="state" name="state" class="form-control required">
                                <option value="">==请录入状态==</option>
                            </select>
                        </td>
                        <th class="formTitle">开发商</th>
                        <td class="formValue"><input id="developer" name="developer" type="text" maxlength="100" class="form-control" placeholder="请录入开发商" /></td>
                    </tr>
                    <tr>
                        <th class="formTitle">BD人员<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="db_admin_id" name="db_admin_id" type="hidden" />
                            <input id="db_admin" name="db_admin" type="text" class="form-control required" placeholder="请录入BD人员" />
                        </td>
                        <th class="formTitle">运维人员<span style="color:red">*</span></th>
                        <td class="formValue">
                            <input id="Mocha_ITOM" name="Mocha_ITOM" type="hidden" />
                                <input id="Mocha_ITOM_admin" name="Mocha_ITOM_admin" onclick="btn_selectUser('Mocha_ITOM')" type="text" class="form-control required" placeholder="请录入运维人员" />
                               
                        </td>
                    </tr>
                </table>
            </div>
        </form>


        <div style="margin-bottom:30px;">
            <table class="form" style="margin-top:10px;">
                <tr>
                    <td colspan="6" class="interval">场地照片</td>
                </tr>
                <tr>
                    <th class="formTitle">图片上传（支持多选批量上传）</th>
                    <td class="formValue" colspan="2">
                        <input id="PhotoFile" accept="image/*" disabled="disabled" class="form-control" type="file" name="filesf" multiple />
                    </td>
                    <td colspan="3">
                        @*<input id="F_FilesBtn" onclick="uploadSend('PhotoFile','Site')" type="button" value="上传图片" class="btn btn-primary" />*@
                        <input id="Is_Down" onclick="checkIsDown()" value="批量下载" class="btn btn-primary" type="button" />
                    </td>
                </tr>
                <tr>
                    <td colspan="4" id="pList">
                        <div id="photoList" style="margin-left:40px;height:190px;">
                        </div>
                    </td>
                    <td colspan="2">
                        <div id="displaydiv" style="display:none"></div>
                        <p>
                            <span style="color:forestgreen">提示：</span>
                            此处请上传场地照片3-10张（外观空景照片3-5张），为保证您所上传的图片资料给到客户更好的展示效果，
                            请提供长宽比为4:3的常规横向展示照片，最小尺寸（790*526），如上传的图片不符合这一要求，我们将会默认裁剪为适合的显示比例。
                            图片要求清晰，单张最大不超过10MB
                        </p>
                    </td>
                </tr>
            </table>
        </div>
        <div style="margin-bottom:50px;">
            <table class="form" style="margin-top:10px;">
                <tr>
                    <td colspan="6" class="interval">其他资料</td>
                </tr>
                <tr>
                    <th class="formTitle">资料上传（支持多选批量上传）</th>
                    <td class="formValue" colspan="2">
                        <input id="filesf" class="form-control" disabled="disabled" type="file" name="filesf" multiple />
                    </td>
                    <td>
                        @*<input id="F_FilesBtn" onclick="uploadSend('filesf','SiteFiles')" type="submit" value="上传资料" class="btn btn-primary" />*@
                    </td>
                    <td colspan="2">
                        <p>
                            <span style="color:forestgreen">提示：</span> 此处请上传场地相关文件，例如：场地勘场报告；进退场须知；场地方版本原始资料PPT；场地广告位区位资料；其他资料等。上传文件大小请控制在单个文件30MB之内
                        </p>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle"></th>
                    <td colspan="3">
                        <div id="imgrq"></div>
                        <div id="imgrq1" style="margin-top:20px;"></div>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">空间小视频（支持多选批量上传）</th>
                    <td class="formValue" colspan="2">
                        <input id="SiteVideoFile" class="form-control" disabled="disabled" accept="video/*" type="file" name="SpaceVideoFile" multiple />
                    </td>
                    <td>
                        @*<input id="F_VideoFilesBtn" onclick="uploadSend('SiteVideoFile','SiteVideo')" type="button" value="上传视频" class="btn btn-primary" />*@
                    </td>
                    <td colspan="2">
                        <p>
                            <span style="color:forestgreen">提示：</span>此处可以上传一些有关场地的实景小视频，有助于客户更直观地了解您的场地，单个文件大小请控制在10MB以内
                        </p>
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td class="formValue" colspan="3">
                        <div id="VideoList">
                        </div>
                    </td>
                </tr>
            </table>
        </div>

        @*<div id="submit_btn" style="margin-bottom:50px;text-align:right; width:80%;">
            <input id="F_submitBtn" onclick="submitForm()" type="submit" value="确定保存" class="btn btn-primary" />
        </div>*@
    </div>
    <div role="tabpanel" class="tab-pane" id="profile">
        <div style="margin:10px; text-align:right;">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
            @*<div class="btn-group">
                <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-eraser"></i>添加空间</a>
            </div>
            <div class="btn-group">
                <a id="NF-edit" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改空间</a>
            </div>
            <div class="btn-group">
                <a id="NF-editAllPrice" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_editAllPrice()"><i class="fa fa-pencil-square-o"></i>整体调价</a>
            </div>*@
            <div class="btn-group">
                <a id="NF-Server" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_editServer()"><i class="fa fa-pencil-square-o"></i>增值服务</a>
            </div>
            <div class="btn-group">
                <a id="NF-schedule" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_schedule()"><i class="fa fa-pencil-square-o"></i>档期管理</a>
            </div>
        </div>
        <div class="gridPanel">
            <table id="Space_gridList"></table>
            <div id="gridPager"></div>
        </div>
    </div>

    <div role="tabpanel" class="tab-pane" id="Activities">
        @*<div style="margin:10px; text-align:right;">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
            <a id="ActivitiesNF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add_Activities()"><i class="fa fa-eraser"></i>添加活动案例</a>
            <a id="ActivitiesNF-edit" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_edit_Activities()"><i class="fa fa-pencil-square-o"></i>修改活动案例</a>
            <a id="ActivitiesNF-delete" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_delete_Activities()"><i class="fa fa-trash-o"></i>删除活动案例</a>
        </div>*@

        <div class="gridPanel">
            <table id="ActivitiesgridList"></table>
            <div id="ActivitiesgridPager"></div>
        </div>

    </div>
    <div role="tabpanel" class="tab-pane" id="success">
        <div class="gridPanel" style="margin:10px;">
            <table id="successgridList"></table>
            <div id="successgridPager"></div>
        </div>

    </div>
    <div role="tabpanel" class="tab-pane" id="Jump">
        <div class="gridPanel" style="margin:10px;">
            <table id="successgridList"></table>
            <div id="successgridPager"></div>
        </div>

    </div>
</div>
<script>
    function getPath(filePath, type) {
        if (filePath != "") {
            var urllist = filePath.split('/');
            if (type == "PDF") {

                var argsId = "F_AttachmentFile";
                var setValId = "F_Attachment";
                var hrefId = "F_AttachmentA";

                document.getElementById(setValId).value = filePath;
                document.getElementById(hrefId).href = filePath;
                document.getElementById(hrefId).innerHTML = urllist[urllist.length - 1];
                document.getElementById(hrefId).style.display = 'block'
            }
            else if (type == "PPT") {
                var argsId = 'F_AttachmentPptFile';
                var setValId = 'F_AttachmentPpt'
                var hrefId = 'F_AttachmentPptA';

                document.getElementById(setValId).value = filePath;
                document.getElementById(hrefId).href = filePath;
                document.getElementById(hrefId).innerHTML = urllist[urllist.length - 1];
                document.getElementById(hrefId).style.display = 'block'
            }

        }
    }
    function btn_add_Activities() {
        $.modalOpen({
            id: "ActivitiesForm",
            title: "新增场地活动案例",
            url: "/SiteManage/ActivitiesCase/Form?id=" + formid + "&siteId=" + keyValue,
            width: "1200px",
            height: "700px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }

    function btn_edit_Activities() {
        var F_Id = $("#ActivitiesgridList").jqGridRowValue().F_Id;
        $.modalOpen({
            id: keyValue,
            title: "修改场地活动案例",
            url: "/SiteManage/ActivitiesCase/Form?id=" + formid + "&siteId=" + keyValue + "&keyValue=" + F_Id,
            width: "1200px",
            height: "720px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
    function btn_delete_Activities() {
        $.deleteForm({
            url: "/SiteManage/ActivitiesCase/DeleteForm",
            param: { keyValue: $("#ActivitiesgridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#ActivitiesgridList").trigger("reloadGrid");
            }
        })
    }

    function getSpace(cellvalue) {
        if (cellvalue != undefined) {
            for (var i = 0; i < Spacedata.length; i++) {
                if (Spacedata[i].F_Id.toString() === cellvalue.toString()) {
                    cellvalue = Spacedata[i].title;
                    break;
                }
            }
        }
        return cellvalue;
    }
    function ActivitiesgridList(ItemList) {
        var $gridList = $("#ActivitiesgridList");
        var queryJson = {
            keyword: $("#txt_keyword").val(),
            F_SiteId: keyValue,
        }
        $gridList.dataGrid({
            url: "/SiteManage/ActivitiesCase/GetGridJson",
            postData: { queryJson: JSON.stringify(queryJson) },
            height: $(window).height() - 205,
            colModel: [
                { label: '编号', name: 'F_Id', hidden: true },
                {
                    label: '所属空间', name: 'F_SpaceId', width: 100, align: 'left',
                    formatter: function (cellvalue) {
                        return getSpace(cellvalue);
                    }
                },
                { label: '活动名称', name: 'F_ActivitiesTitle', width: 200, align: 'left' },
                {
                    label: '活动类型', name: 'F_ActivitiesType', width: 200, align: 'left',
                    formatter: function (cellvalue) {
                        return FMDictionaries(ItemList.ActivityType, cellvalue);
                    }
                },
                { label: '活动人数', name: 'F_ActivitiesNumber', width: 100, align: 'left' },
                {
                    label: '活动开始时间', name: 'F_StarDate', width: 150, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }
                },
                {
                    label: '活动结束时间', name: 'F_EndDate', width: 150, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }
                }
            ],
            pager: "#ActivitiesgridPager",
            sortname: 'F_Id desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }



    function successgridList() {
        var $gridList = $("#successgridList");
        var flowStateArr = ['订单指派', '场地推荐', '带看场地', '意向场地', '价格谈判', '场地预定', '签订合同', '订单完成'];
        var stateArr = ['等待确认', '通过', '驳回'];

        $gridList.dataGrid({
            url: "/OrderFlowManage/ClientOrder/GetGridJson",
            height: $(window).height() - 176,
            colModel: [
                { label: '编号', name: 'F_Id', hidden: true },
                { label: '活动城市', name: 'F_ActivityCityName', width: 80, align: 'left' },
                {
                    label: '使用日期', name: 'F_ActivityStartDate', width: 160, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        var start = cellvalue ? cellvalue.split(' ')[0] : '';
                        var end = rowObject.F_ActivityEndDate ? rowObject.F_ActivityEndDate.split(' ')[0] : '';
                        return start + '~' + end;
                    }
                },
                { label: '活动名称', name: 'F_ActivityTheme', width: 100, align: 'left' },
                { label: '活动类型', name: 'F_SiteTypeName', width: 80, align: 'left' },
                {
                    label: '预算金额(元)', name: 'F_DemandCash', width: 100, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        ;
                        return (cellvalue || "").toString();
                    }
                },
                { label: '场地大小(㎡)', name: 'F_SiteArea', width: 100, align: 'left' },
                { label: '联系人', name: 'F_Contact', width: 80, align: 'left' },
                { label: '公司名称', name: 'F_ClientName', width: 100, align: 'left' },
                {
                    label: '当前订单状态', name: 'F_OrderState', width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        // 0指派1场地推荐2带看场地3意向场地4价格谈判5场地预定6签订合同7订单完成
                        return flowStateArr[cellvalue];
                    }
                },
                {
                    label: '当前订单进度', name: 'F_OrderStateProcess', width: 80, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        // -1 等待跟进  0等待确认    1通过    2驳回
                        return cellvalue == -1 ? "等待跟进" : stateArr[cellvalue];
                    }
                },
                { label: '跟进人', name: 'F_FlowUserName', width: 80, align: 'left' },

                {
                    label: '更新时间', name: 'F_LastModifyTime', width: 100, align: 'center',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                },
                {
                    label: '创建时间', name: 'F_CreatorTime', width: 100, align: 'center',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                }
            ],
            pager: "#gridPager",
            sortname: 'F_LastModifyTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            var queryJson = {
                keyword: $("#txt_keyword").val(), orderstate: $("#orderstate").val()
            };
            $gridList.jqGrid('setGridParam', {
                postData: { queryJson: JSON.stringify(queryJson) },
            }).trigger('reloadGrid');
        });
    }
</script>


